package com.example.test3;

import java.util.function.Consumer;

public class Demo3 {

    public static void main(String[] args) {

        /*
        printSum(a -> {
            int sum = 0;
            for(int i: a) {
                sum += i;
            }
            System.out.println("sum:" + sum);
        });
         */

        printSum(Demo3::getTotal);

    }

    private static void getTotal(int[] a) {
        int sum = 0;
        for(int i: a) {
            sum += i;
        }
        System.out.println("sum:" + sum);
    }

    private static void printSum(Consumer<int[]> consumer) {
        int[] a = {10, 20, 30, 40, 50, 60};
        consumer.accept(a);
    }

}
